Skip to content

updating episodic memory prompts#11

Merged
aayush3011 merged 3 commits into
AzureCosmosDB:mainfrom
aayush3011:users/akataria/conflictResolutionImprovements
May 7, 2026
Merged

updating episodic memory prompts#11
aayush3011 merged 3 commits into
AzureCosmosDB:mainfrom
aayush3011:users/akataria/conflictResolutionImprovements

Conversation

@aayush3011

Copy link
Copy Markdown
Contributor

No description provided.

@aayush3011 aayush3011 marked this pull request as ready for review May 7, 2026 19:29
Copilot AI review requested due to automatic review settings May 7, 2026 19:29
@aayush3011 aayush3011 merged commit f667234 into AzureCosmosDB:main May 7, 2026
7 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the toolkit’s episodic-memory extraction contract to support “scoped” episodic memories (via scope_type / scope_value), and modernizes the read-side filtering APIs to support multi-type retrieval via memory_types=[...]. It also changes get_user_summary() to read a single deterministic document (or return None) instead of querying and returning a list, with corresponding test/sample/doc updates.

Changes:

  • Update episodic extraction prompt + pipeline handling to require scope_type/scope_value and allow episodic memories without the situation/action/outcome triple.
  • Add multi-type filtering support (IN (...)) via a new query builder helper and propagate it through get_memories, get_thread, search_cosmos, and get_local.
  • Switch get_user_summary() to read_item with deterministic id/PK and update tests + samples accordingly.

Reviewed changes

Copilot reviewed 30 out of 30 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/unit/test_query_builder.py Adds unit tests for new add_in_filter() behavior.
tests/unit/test_pipeline_confidence.py Expands tests for scoped episodic extraction + content fallback behavior.
tests/unit/test_memory_type_multi.py New tests ensuring memory_types flows into generated Cosmos SQL (IN clause).
tests/unit/test_cosmos_memory_client.py Updates sync client tests for memory_types and single-doc get_user_summary().
tests/unit/aio/test_cosmos_memory_client.py Updates async client tests for single-doc get_user_summary().
tests/integration/test_processor_integration.py Updates integration assertions to use memory_types.
tests/integration/test_processor_integration_async.py Updates async integration assertions to use memory_types.
tests/integration/test_full_pipeline.py Updates integration tests to use memory_types and new get_user_summary() return shape.
Samples/scenario_rag_with_memory.py Updates sample to handle singular user summary doc shape.
Samples/scenario_memory_reconciliation.py Updates sample retrieval calls to memory_types.
Samples/scenario_customer_support.py Updates sample retrieval calls and user summary access.
Samples/processing_user_profile.py Updates user summary readback to handle Optional[dict].
Samples/processing_thread_summary.py Updates summary retrieval to memory_types=["summary"].
Samples/processing_fact_extraction.py Updates per-type retrieval to memory_types=[kind].
Samples/Demo.ipynb Updates notebook cells for get_local / get_memories / get_user_summary shape changes.
Samples/Demo_function_app.ipynb Updates notebook text/cells to use memory_types in retrieval examples.
Samples/Demo_function_app_async.ipynb Updates async notebook retrieval examples to memory_types.
Samples/Demo_async.ipynb Updates async notebook retrieval examples and user summary access.
Samples/advanced_memory_lifecycle.py Updates archive loop to use memory_types=["turn"].
README.md Updates retrieval example to use memory_types=["fact"].
function_app/triggers/change_feed.py Minor simplification of should_reconcile assignment.
Docs/local_testing.md Updates example to use memory_types=["summary"].
Docs/design_patterns.md Updates documentation examples to use memory_types.
Docs/azure_testing.md Updates documentation examples to use memory_types.
agent_memory_toolkit/prompts/extract_memories.prompty Revises episodic prompt section for scoped episodic memories + updated schema.
agent_memory_toolkit/pipeline.py Implements scoped episodic validation + deterministic content fallback chain.
agent_memory_toolkit/cosmos_memory_client.py Introduces memory_types read filters, IN-clause usage, and single-doc get_user_summary().
agent_memory_toolkit/aio/cosmos_memory_client.py Async parity for memory_types filters and single-doc get_user_summary().
agent_memory_toolkit/_utils.py Updates _build_memory_query_builder() to apply multi-type IN filter.
agent_memory_toolkit/_query_builder.py Adds add_in_filter() helper to generate parameterized IN (...) clauses.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

"lesson": "transferable takeaway or null",
"domain": "topic area",
"scope_type": "trip|project|event|session|release|campaign|... (free-form, required, non-empty)",
"scope_value": "specific instance, e.g. Paris 2025 (required, non-empty)",
@@ -1239,10 +1242,6 @@ def search_cosmos(
3. Optionally filters by the remaining keyword parameters.
4. Returns up to *top_k* results ordered by similarity.

Comment on lines 183 to 187
summaries = mem.get_user_summary(user_id=user_id)
if summaries:
print(f" Found {len(summaries)} summary document(s):")
for s in summaries:
print(f" • {s.get('content', '')[:120]}")
print(" Found user summary:")
print(f" • {summaries.get('content', '')[:120]}")
else:
Comment thread README.md
Comment on lines 201 to 206
Filter at retrieval time:

```python
results = memory.search_cosmos("user preferences", user_id="u1", min_confidence=0.7)
high_conf_facts = memory.get_memories(user_id="u1", memory_type="fact", min_confidence=0.7)
high_conf_facts = memory.get_memories(user_id="u1", memory_types=["fact"], min_confidence=0.7)
```
@aayush3011 aayush3011 deleted the users/akataria/conflictResolutionImprovements branch May 21, 2026 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants